﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="NewEmployee.aspx.cs" Inherits="MonkeyWarranty.Web.InstantTickets.NewEmployee" %>
<%@ Import Namespace="Resources" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <title>
        <%=Resources.GlobalStrings.InstantTicketForm %> - <%=Resources.GlobalStrings.WarrantyEmployees %></title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="row">
        <div class="col-lg-12">
            <h3><%=GlobalStrings.InstantTicketForm %> <%=GlobalStrings.WarrantyEmployees %></h3>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="alert alert-danger" runat="server" id="errorMessage" visible="False">
                <label class="control-label">
                    <asp:Literal ID="lblErrorMessage" runat="server"></asp:Literal></label>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <%=GlobalStrings.OutsideService %>
                </div>
                <div class="panel-body">
                    <div class="col-lg-6">
                        <div class="form-group">
                            <asp:HiddenField ID="hidEmployeeId" runat="server" />
                            <div class="form-group">
                                <label><%=GlobalStrings.Employees%></label><br/>
                                <asp:TextBox ID="txtEmployeeName" runat="server" ReadOnly="True" CssClass="textEntry name"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtEmployeeName"
                                    CssClass="failureNotification" ValidationGroup="AddNew">(*)</asp:RequiredFieldValidator>
                                <a href="javascript:void(0);" onclick="javascript:SelectEmployee();" data-toggle="modal" data-target="#employeeModal">Select</a>
                            </div>
                            <div class="form-group">
                                <label><%=GlobalStrings.StartDate %></label><br/>
                                <asp:TextBox ID="txtStartDate" runat="server" CssClass="textEntry date"></asp:TextBox>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6">
                        <div class="form-group">
                            <label><%=GlobalStrings.Description %></label>
                            <asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" CssClass="form-control"></asp:TextBox>
                        </div>
                        <div class="form-group">
                            <label><%=GlobalStrings.Note %></label>
                            <asp:TextBox ID="txtNote" runat="server" TextMode="MultiLine" CssClass="form-control"></asp:TextBox>
                        </div>
                    </div>
                    <div class="col-lg-12">
                        <asp:Button ID="btnSave" runat="server"
                            Text="<%$ Resources:GlobalStrings, Save %>" CssClass="btn btn-primary" Width="100px"
                            OnClick="btnSave_Click" />
                        <a class="btn btn-default" href="Edit.aspx?id=<%=Request.Params["ticketId"] %>#tabs-3"><%=GlobalStrings.Cancel %></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Employees Modal -->
    <div class="modal fade" id="employeeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width: 850px; height: 400px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel"><%=GlobalStrings.EmployeesList %></h4>
                </div>
                <div class="modal-body">
                    <div id="EmployeesTableContainer"></div>
                    <p></p>
                    <a class="btn btn-success" href="../Employees/New.aspx" target="_blank"><%=GlobalStrings.AddNew %></a>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->

    <script type="text/javascript">
        $(function () {
            $("#menu-instant").addClass("active");

            $("#<%=txtEmployeeName.ClientID %>").prop("disabled", true);
            $("#<%=txtStartDate.ClientID %>").calendar();

            //Prepare jtable plugin
            $('#EmployeesTableContainer').jtable({
                paging: false,
                pageSize: 10,
                sorting: false,
                actions: {
                    listAction: '../Employees/List.aspx/EmployeeList'
                },
                fields: {
                    Id: {
                        key: true,
                        create: false,
                        edit: false,
                        list: false
                    },
                    Code: {
                        title: '<%=GlobalStrings.Code %>'
                    },
                    Name: {
                        title: '<%=GlobalStrings.Name %>',
                        width: '20%',
                        display: function (data) {
                            return '<a href="javascript:void(0);" data-dismiss="modal" onclick="javascript:EmployeeSelect({Id:' + data.record.Id +
                            ',Code:\'' + data.record.Code + '\'' +
                                ',Name:\'' + data.record.Name + '\'' +
                                    '});">' + data.record.Name + '</a>';
                        }
                    }
                }
            });
        });
    </script>
    
    <script type="text/javascript">
        function EmployeeSelect(employee) {
            $("#<%=hidEmployeeId.ClientID %>").val(employee.Id);
            $("#<%=txtEmployeeName.ClientID %>").val(employee.Name);
        }

        function SelectEmployee() {
            // load data
            $('#EmployeesTableContainer').jtable('load');
        }
    </script>
</asp:Content>
